home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 2
/
Amiga Tools 2.iso
/
tex
/
mf
/
inputs
/
passaulogos
/
unilogos.mf
< prev
next >
Wrap
Text File
|
1995-03-15
|
11KB
|
365 lines
def SetZ( expr n, v ) =
x[n] := xpart(v);
y[n] := ypart(v);
enddef;
def OverwriteSystem = true enddef;
def NoOverwriteSystem = false enddef;
numeric STD_INPUTSCALEX; % Standard Eingabeskalierung in X-Richtung
numeric STD_INPUTSCALEY; % Standard Eingabeskalierung in Y-Richtung
numeric STD_OUTPUTSCALEX; % Standard Ausgabeskalierung in X-Richtung
numeric STD_OUTPUTSCALEY; % Standard Ausgabeskalierung in Y-Richtung
STD_INPUTSCALEX = 1;
STD_INPUTSCALEY = 1;
STD_OUTPUTSCALEX = 1;
STD_OUTPUTSCALEY = 1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%% Datenstruktur der Koordinatensysteme als Stapel:
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Der SystemStack wird in den Bereich der z-Variablen gelegt.
%%% Ein System besteht aus den folgenden Komponenten:
% - (2) pair Nullpunkt
% - (2) pair Basisvektor1
% - (1) numeric Eingabe-Streckungsfaktor Basisvektor1
% - (1) numeric Ausgabe-Streckungsfaktor Basisvektor1
% - (2) pair Basisvektor2
% - (1) numeric Eingabe-Streckungsfaktor Basisvektor2
% - (1) numeric Ausgabe-Streckungsfaktor Basisvektor2
% - (1) numeric Drehwinkel Basisvektor2
% - (1) numeric Drehwinkel Basisvektor2
% (6) Speicherplaetze in der Summe als Pair.
%%% Variablen:
numeric MAXSYSTEMS; % Maximale Zahl verschachtelter Systeme
numeric SYS_PAIRS; % Anzahl Speicherplaetze eines Systems
numeric SYS_STACKMIN; % Untere Grenze des SystemStacks
numeric SYS_STACKMAX; % Obere Grenze des SystemStacks
numeric SYS_TOP; % Zeiger auf oberstes SystemStackElement
numeric SysRecDepth_Max;
numeric SysRecDepth_UserMaximal;
numeric SysRecDepth_UserActual;
MAXSYSTEMS = 10; % Maximal 10 Systeme verschachtelt.
SYS_PAIRS = 6;
SYS_STACKMIN = 0; % SYS_STACK kommt zuerst im Speicher.
% Platz fuer das Root-System muss reserviert werden:
SYS_STACKMAX = SYS_STACKMIN + ((MAXSYSTEMS+1) * SYS_PAIRS - 1);
% SystemInformationen:
SysRecDepth_Max = MAXSYSTEMS;
SysRecDepth_UserMaximal = 0;
SysRecDepth_UserActual = 0;
%%% Zugriffsoperationen:
def Origin = z[SYS_TOP+0] enddef;
def BaseX = z[SYS_TOP+1] enddef;
def BaseY = z[SYS_TOP+2] enddef;
def InputScaleX = xpart(z[SYS_TOP+3]) enddef;
def InputScaleY = ypart(z[SYS_TOP+3]) enddef;
def OutputScaleX = xpart(z[SYS_TOP+4]) enddef;
def OutputScaleY = ypart(z[SYS_TOP+4]) enddef;
def RotationX = xpart(z[SYS_TOP+5]) enddef;
def RotationY = ypart(z[SYS_TOP+5]) enddef;
def SystemDepth = (SYS_TOP/SYS_PAIRS) enddef;
def FatherOrigin = z[SYS_TOP-SYS_PAIRS+0] enddef;
def FatherBaseX = z[SYS_TOP-SYS_PAIRS+1] enddef;
def FatherBaseY = z[SYS_TOP-SYS_PAIRS+2] enddef;
def FatherInputScaleX = xpart(z[SYS_TOP-SYS_PAIRS+3]) enddef;
def FatherInputScaleY = ypart(z[SYS_TOP-SYS_PAIRS+3]) enddef;
def FatherOutputScaleX = xpart(z[SYS_TOP-SYS_PAIRS+4]) enddef;
def FatherOutputScaleY = ypart(z[SYS_TOP-SYS_PAIRS+4]) enddef;
def FatherRotationX = xpart(z[SYS_TOP-SYS_PAIRS+5]) enddef;
def FatherRotationY = ypart(z[SYS_TOP-SYS_PAIRS+5]) enddef;
def InitSystemStack =
% Setzen des Root-Systemes, das nicht veraendert werden kann:
SetZ( SYS_STACKMIN+0, (0,0) );
SetZ( SYS_STACKMIN+1, (1,0) );
SetZ( SYS_STACKMIN+2, (0,1) );
SetZ( SYS_STACKMIN+3, (STD_INPUTSCALEX, STD_INPUTSCALEY ) );
SetZ( SYS_STACKMIN+4, (STD_OUTPUTSCALEX,STD_OUTPUTSCALEY) );
SetZ( SYS_STACKMIN+5, (0,0) );
% Zeiger auf das oberste Stackelement wird auf das
% zweite Stackelement gesetzt, da das erste das
% Root-System ist und nicht geaendert werden darf:
SYS_TOP := SYS_STACKMIN + SYS_PAIRS;
% Setzen des ersten Systemes auf Standard-Werte:
SetZ( SYS_STACKMIN+SYS_PAIRS+0, (0,0) );
SetZ( SYS_STACKMIN+SYS_PAIRS+1, (1,0) );
SetZ( SYS_STACKMIN+SYS_PAIRS+2, (0,1) );
SetZ( SYS_STACKMIN+SYS_PAIRS+3, ( CharWidth, CharHeight ) );
SetZ( SYS_STACKMIN+SYS_PAIRS+4, ( CharWidth, CharHeight ) );
SetZ( SYS_STACKMIN+SYS_PAIRS+5, (0,0) );
% Anzeigen Stack-Groesse:
% showvariable MAXSYSTEMS;
enddef;
def CreateSystem( expr Null,
PInputScaleX, POutputScaleX, RotX,
PInputScaleY, POutputScaleY, RotY,
Overwrite
) =
% Aktuelles System soll nicht ueberschrieben werden? ->
% Erst ein neues Stapelelement erzeugen.
if not Overwrite:
SYS_TOP := SYS_TOP + SYS_PAIRS;
if ((SYS_TOP-SYS_STACKMIN)/SYS_PAIRS)-1
> SysRecDepth_UserMaximal:
SysRecDepth_UserMaximal := SYS_TOP-SYS_PAIRS
fi
fi;
% Nullpunkt bzgl. Vatersystem berechnen und eintragen:
SetZ( SYS_TOP+0, FatherOrigin +
( xpart(Null)/FatherInputScaleX*FatherOutputScaleX
*
FatherBaseX
)
+
( ypart(Null)/FatherInputScaleY*FatherOutputScaleY
*
FatherBaseY
) );
% Basisvektor1: die Drehung wird zur Drehung des
% Vater-Basisvektors1 addiert.
SetZ( SYS_TOP+1, FatherBaseX rotated RotX );
% Basisvektor2: die Drehung wird zur Drehung des
% Vater-Basisvektors2 addiert.
SetZ( SYS_TOP+2, FatherBaseY rotated RotY );
SetZ( SYS_TOP+3, ( PInputScaleX, PInputScaleY ) );
SetZ( SYS_TOP+4,
( (POutputScaleX/FatherInputScaleX)*CharWidth,
(POutputScaleY/FatherInputScaleY)*CharHeight
) );
% Rotationswinkel werden einfach addiert
% und nur der Genauigkeit wegen mit abgespeichert.
SetZ( SYS_TOP+5, ( RotX + FatherRotationX,
RotY + FatherRotationY ) );
enddef;
def PrintSystem =
pair origin;
pair x_base;
pair y_base;
numeric x_inputscale;
numeric y_inputscale;
numeric x_outputscale;
numeric y_outputscale;
numeric x_rotation;
numeric y_rotation;
numeric system_nesting_deepness;
system_nesting_deepness = SystemDepth;
origin = Origin;
x_base = BaseX;
y_base = BaseY;
x_inputscale := InputScaleX;
y_inputscale := InputScaleY;
x_outputscale := OutputScaleX;
y_outputscale := OutputScaleY;
x_rotation := RotationX;
y_rotation := RotationY;
show " ##### datas of the actual system:";
showvariable system_nesting_deepness;
showvariable origin;
showvariable x_base;
showvariable x_inputscale;
showvariable x_outputscale;
showvariable x_rotation;
showvariable y_base;
showvariable y_inputscale;
showvariable y_outputscale;
showvariable y_rotation;
enddef;
def ChangeSystem( expr Null,
InputScaleX, OutputScaleX, RotX,
InputScaleY, OutputScaleY, RotY
) =
CreateSystem( Null,
InputScaleX, OutputScaleX, RotX,
InputScaleY, OutputScaleY, RotY,
OverwriteSystem
)
enddef;
def EnterSystem( expr Null,
InputScaleX, OutputScaleX, RotX,
InputScaleY, OutputScaleY, RotY
) =
if SYS_TOP + SYS_PAIRS < SYS_STACKMAX:
CreateSystem( Null,
InputScaleX, OutputScaleX, RotX,
InputScaleY, OutputScaleY, RotY,
NoOverwriteSystem
)
% else:
% show " ";
% show " System-Stack-Overflow: (EnterSystem) ";
% show " Your systems are too deeply nested!";
% show " If you really want to nest your systems deeper, ";
% show " then you should enlarge the SystemStack: ";
% showvariable MAXSYSTEMS;
% errmessage "Sorry";
fi;
enddef;
def LeaveSystem =
if SYS_TOP > (SYS_STACKMIN + SYS_PAIRS):
SYS_TOP := SYS_TOP - SYS_PAIRS;
else:
show " ";
show " System-Stack-Underflow: (LeaveSystem) ";
show " There is no more System to leave! ";
errmessage "Sorry";
fi;
enddef;
def CopySystem =
EnterSystem( (0,0), InputScaleX, InputScaleX, 0,
InputScaleY, InputScaleY, 0
)
enddef;
def MoveSystem( expr xp, yp ) =
SetZ( SYS_TOP+0, z[SYS_TOP+0]
+ (xp/InputScaleX*OutputScaleX*BaseX)
+ (yp/InputScaleY*OutputScaleY*BaseY) )
enddef;
def ScaleSystem( expr xp, yp ) =
SetZ( SYS_TOP+4, (xp*x[SYS_TOP+4], yp*y[SYS_TOP+4]) )
enddef;
def SetInputScale( expr xp, yp ) =
SetZ( SYS_TOP+3, (xp, yp) )
enddef;
def SetOutputScale( expr xp, yp ) =
SetZ( SYS_TOP+4, (xp*FatherOutputScaleX, yp*FatherOutputScaleY) )
enddef;
def RotateSystem( expr xp, yp ) =
SetZ( SYS_TOP+5, (xp+x[SYS_TOP+5], yp+y[SYS_TOP+5]) );
SetZ( SYS_TOP+1, FatherBaseX rotated RotationX );
SetZ( SYS_TOP+2, FatherBaseY rotated RotationY );
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%% Datenstruktur der Punkte (Koordinatenpaare) als Stapel:
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Variablen:
numeric POINT_STACKMIN; % Untere Grenze des PunkteStacks
numeric POINT_TOP; % Zeiger auf oberstes PunkteStackElement
%%% SystemInformationen:
numeric UserPoints;
UserPoints = 0;
def InitPointStack =
POINT_STACKMIN = SYS_STACKMAX + 1;
POINT_TOP = POINT_STACKMIN;
enddef;
def point( expr pp ) =
x[POINT_TOP] := xpart(pp);
y[POINT_TOP] := ypart(pp);
POINT_TOP := POINT_TOP + 1;
UserPoints := UserPoints+1;
enddef;
def thelastpoint = POINT_TOP-1 enddef;
def thenextpoint = POINT_TOP enddef;
def next( expr p, n ) =
Origin + ((x[p+n]/InputScaleX)*OutputScaleX)*BaseX
+ ((y[p+n]/InputScaleY)*OutputScaleY)*BaseY
enddef;
def thepoint( expr p ) = next( p, 0 );
enddef;
def last( expr n ) =
Origin + ((x[POINT_TOP-1-n]/InputScaleX)*OutputScaleX)*BaseX
+ ((y[POINT_TOP-1-n]/InputScaleY)*OutputScaleY)*BaseY
enddef;
def this( expr px, py ) =
Origin + ((px/InputScaleX)*OutputScaleX)*BaseX
+ ((py/InputScaleY)*OutputScaleY)*BaseY
enddef;
def tan( expr px, py ) =
((px/InputScaleX)*OutputScaleX)*BaseX +
((py/InputScaleY)*OutputScaleY)*BaseY
enddef;
def SystemInfo =
show "### SystemInfo:";
SysRecDepth_UserActual := (SYS_TOP/SYS_PAIRS)-1;
showvariable SysRecDepth_Max;
showvariable SysRecDepth_UserMaximal;
showvariable SysRecDepth_UserActual;
showvariable UserPoints;
show "";
enddef;
def ShowSystem =
pickup pencircle;
draw this( 0,0 )--
this( InputScaleX,0 )--
this( InputScaleX,InputScaleY )--
this( 0,InputScaleY )--cycle;
enddef;
def InitSystems =
InitSystemStack;
InitPointStack
enddef;
InitSystems;